#include "include/bbullet.h"

bBullet::bBullet(float gravX, float gravY, float gravZ)
{
	this->collisionConfiguration	= new btDefaultCollisionConfiguration();
	this->dispatcher				= new btCollisionDispatcher(this->collisionConfiguration);
	this->overlappingPairCache	= new btDbvtBroadphase();
	this->solver					= new btSequentialImpulseConstraintSolver;
	this->dynamicsWorld			= new btDiscreteDynamicsWorld(this->dispatcher, this->overlappingPairCache, this->solver, this->collisionConfiguration);
	this->dynamicsWorld->setGravity(btVector3(btScalar(gravX), btScalar(gravY), btScalar(gravZ)));
}

bBullet::~bBullet()
{
	delete this->collisionConfiguration;
	delete this->dispatcher;
	delete this->overlappingPairCache;
	delete this->solver;
	delete this->dynamicsWorld;
}

btDiscreteDynamicsWorld* bBullet::getDynamicsWorld()
{
	return this->dynamicsWorld;
}

void bBullet::Update(btScalar timeStep, int maxSubSteps, btScalar fixedTimeStep)
{
	this->dynamicsWorld->stepSimulation(timeStep, maxSubSteps, fixedTimeStep);
}

void bBullet::Update()
{
	this->dynamicsWorld->stepSimulation(1.f/60.f,10);
}